package com.algorithm;

import java.util.Arrays;

public class Main {


    public static void main(String[] args) {

        int[] ints = twoSum(new int[]{2, 7, 11, 15}, 9);

        System.out.println(Arrays.toString(ints));

    }
    public static int[] twoSum(int[] numbers, int target) {

        int left=0,right=numbers.length-1;

        while(left<right){

            int sum=numbers[left]+numbers[right];

            if(sum==target){

                return new int[]{left,right};
            }

            if(sum>target){
                right--;
            }else{
                left++;
            }

        }

        return new int[]{-1,-1};

    }
}
